<template>
<h2>注册页面</h2>
<table>
    <tr>
        <td>用户名</td>
        <td><input type="text" v-model="info.Uname"></td>
    </tr>
    <tr>
        <td>密码</td>
        <td><input type="password" v-model="info.Upwd"></td>
    </tr>
    <tr>
        <td colspan="2">
            <button @click="Register">注册</button>
        </td>
    </tr>
</table>
</template>
<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router=useRouter()
const info=ref(
    {
        Uname:'',
        Upwd:''
    }
)
const Register=()=>{
    axios.post("https://localhost:44324/api/Lx/Register",
        {
            Uname:info.value.Uname,
            Upwd:info.value.Upwd
        }
    ).then(res=>{
        if(res.data==-1){
            alert("用户名已存在")
        }else if(res.data>0){
            alert("注册成功")
            router.push("/Ulogin")
        }else {
            alert("注册失败")
        }
    })
}


</script>